package org.yuanqiframework.yuanqi.core.utils;

import cn.hutool.core.util.PhoneUtil;

/**
 * @Author 曹波涛
 * @Date 2022/11/9 9:45
 * @Version 1.0
 */
public class PhoneNumUtils extends PhoneUtil {
    /**
     * 获取手机号后4位
     * 例如：150****1110
     * 返回就是 1110
     *
     * @param phoneNum
     * @return
     */
    public static String tail(String phoneNum) {
        if (PhoneUtil.isPhone(phoneNum)) {
            return PhoneUtil.subAfter(phoneNum).toString();
        }
        return phoneNum;
    }

    /**
     * 手机号脱敏
     *
     * @param phoneNum
     * @return 150****1110
     */
    public static String hideBetween(String phoneNum) {
        if (PhoneUtil.isPhone(phoneNum)) {
            return PhoneUtil.hideBetween(phoneNum).toString();
        }
        return phoneNum;
    }
}
